package cn.yh.register.msm.receiver;

import cn.yh.register.common.constant.MqConst;
import cn.yh.register.msm.service.MsmService;
import cn.yh.register.vo.msm.MsmVo;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 短信消费方
 */
@Component
public class MsmReceiver {
    @Autowired
    MsmService msmService;

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = MqConst.QUEUE_MSM_ITEM,durable = "true"),
            exchange = @Exchange(MqConst.EXCHANGE_DIRECT_MSM),
            key = MqConst.ROUTING_MSM_ITEM

    ))
    public void receive(MsmVo msmVo, Message message, Channel channel){
        // 发送短信
        msmService.send(msmVo);

    }

}
